var ns, app, dialog, toast;
app = new Vue({
    el: '#app',
    data: {
        list: [],
        IsApproval:0,//0采购审批
        form: {
            pageindex: 0,
            pagesize: 10,
            keywords:'',
            servicetype: 1, //0-未选择 1-任务工单保修 2-投诉建议
            status: 4, //1-全部 0-处理中 1-已完工 4-待受理 5-待派单 10-待接单 50-已归档=已关单
            RoomID: 0,
            isviewdetail: true,
            onlybaoshi: 0,
            isFirstLoad: 1
        },
        total: {
            WaitCount: 0,
            ProcessCount: 0,//处理中数量
            CompleteCount: 0,//已完工数量
            TotalCount: 0,//全部数量
            OnFileCount: 0,
            ReadCount: 0,//待受理数量
            SendCount: 0,//---待派单数量
            AcceptCount: 0,//---待接单数量
            GuiDangCount: 0,//---已关单数量
        },
        current_item_length:0,
        can_scroll: false,
        is_searching :false,
        
    },
    methods: {
        get_data: function () {
            var that = this;
            that.is_searching = true;
            that.can_scroll = false;
            var options = {};
            options.pagesize = that.form.pagesize;
            options.pageindex = that.form.pageindex;
            options.Keywords = that.form.keywords;
            options.action = "getpurchaserequisitionlist";
            ns.post(options, function (succeed, data, err) {
                that.is_searching = false;
                if (succeed) {

                    if (data.data.length == that.form.pagesize) {
                        that.can_scroll = true;
                    }
                    if (that.form.pageindex == 0) {
                        that.list = data.data;
                    } else {
                        that.list = that.list.concat(data.data);
                    }
                    app.current_item_length = that.list.length;


                    // that.list=data.data;
                }
            }, {
                toast: true
            });
        },
        do_OpenExamineDetails:function(ApprovalID){
            ns.openWin('examine_detail', '审批详情'
                    , {
                        ApprovalID: ApprovalID,
                        IsApproval:0
                        // id: that.form.ID,
                        // type: type,
                        // ServiceType: ServiceType
                    }
                    ); 

        },
        do_search: function() {
            this.get_data();
        },
        
        
       
    }
});
apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    dialog = new auiDialog();
    toast = new auiToast();
    // app.form.servicetype = api.pageParam.servicetype || 1;
    // app.form.RoomID = api.pageParam.id || 0;
    // app.form.isviewdetail = api.pageParam.isviewdetail || false;
    // if (app.form.isviewdetail) {
    //     app.form.status = 4;
    // }
    // app.form.onlybaoshi = api.pageParam.onlybaoshi || 0;
    api.addEventListener({
        name: 'reloadservicelist'
    }, function (ret, err) {
        app.form.isFirstLoad = 1;
        app.get_data();
    });
    api.addEventListener({
        name: 'customerservicelist_frm'
    }, function (ret, err) {
        app.form.isFirstLoad = 1;
        app.get_data();
    });
    api.addEventListener({
        name: 'is_hidden_right',
    }, function (ret, err) {
        app.form.isFirstLoad = 1;
        app.get_data();
    });
    ns.init_pull();
    ns.init_search();
    app.get_data();
    // setTimeout(function () {
    //     app.get_operation();
    // }, 500)
    // api.addEventListener({
    //     name: 'do_open_neibubaoshi'
    // }, function (ret, err) {
    //     ns.openWin('customerservice_history', '我的历史工单', {
    //         servicetype: app.form.servicetype
    //     });
    // });
    // api.addEventListener({
    //     name: 'do_open_service_jindu'
    // }, function(ret, err) {
    //     app.doOpenServiceProcess();
    // });
};
